package com.suntront.lib_db.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.suntront.lib_db.table.Test;

import java.util.List;

@Dao
public interface TestDao {
    @Query("SELECT * FROM test")
    List<Test> getAll();

    @Query("SELECT * FROM test WHERE uid IN (:testIds)")
    List<Test> loadAllByIds(int[] testIds);

    @Query("SELECT * FROM test WHERE first_name LIKE :first AND "
            + "last_name LIKE :last LIMIT 1")
    Test findByName(String first, String last);

    @Insert
    void insertAll(Test... tests);

    @Delete()
    void delete(Test test);

    @Query("DELETE  FROM test")
    void deleteAll();

    @Update
    void update(Test test);

    @Update
    void updateAll(List<Test> list);

    @Query("UPDATE test SET first_name = :first_name WHERE uid = :last_name")
    void updateByLastName(String first_name,String last_name);
}
